home *** CD-ROM | disk | FTP | other *** search
/ Leonardo the Inventor / Leonardo The Inventor (93026)(Broderbund)(Riverdeep)(2004).iso / LEOWINMV / DATABASE.DIR / 00089_Script_TEXT MANIPULATION HANDLERS < prev    next >
Text File  |  1996-03-28  |  2KB  |  63 lines

  1. -- ---------------------------------------------------------------
  2. -- Handler convertToLower returns the given phrase to the 
  3. -- equivalent phrase of all lower case letters.
  4.  
  5. on convertToLower phrase
  6.   set allLower = ""
  7.   set lowerOffset = charToNum("a") - charToNum("A")
  8.   
  9.   repeat with i = 1 to the number of chars in phrase
  10.     set numVal = charToNum(char i of phrase)
  11.     
  12.     if (numVal >= charToNum("A")) and (numVal <= charToNum("Z")) then -- capital
  13.       put numToChar(charToNum(char i of phrase) + lowerOffset) after allLower
  14.     else
  15.       put char i of phrase after allLower
  16.     end if
  17.   end repeat
  18.   return allLower
  19. end
  20.  
  21. -- --------------------------------------------------------
  22. -- Handler endsWithPunctuation returns TRUE if the given word
  23. -- ends with a punctuation mark and returns FALSE otherwise.
  24.  
  25. on endsWithPunctuation whichWord
  26.   set lastChar = the last char of whichWord
  27.   if (lastChar = ".") or (lastChar = "?") or (lastChar = "!") or (lastChar = QUOTE) or (lastChar = ",") or (lastChar = ";") or (lastChar = ")") or (lastChar = "-") then
  28.     return TRUE
  29.   else
  30.     return FALSE
  31.   end if
  32. end
  33.  
  34. -- --------------------------------------------------------
  35. -- Handler beginsWithPunctuation returns TRUE if the given word
  36. -- ends with a punctuation mark and returns FALSE otherwise.
  37.  
  38. on beginsWithPunctuation whichWord
  39.   set firstChar = char 1 of whichWord
  40.   if (firstChar = QUOTE) or (firstChar = "(") or (firstChar = "[") or (firstChar = "'") or (firstChar = "ô") or (firstChar = "æ") or (firstChar = "-") then
  41.     return TRUE
  42.   else
  43.     return FALSE
  44.   end if
  45. end
  46.  
  47. -- --------------------------------------------------------
  48. -- Handler removePunctuationFromEnd returns the given phrase
  49. -- without the ending puncutation
  50.  
  51. on removePunctuationFromEnd phrase
  52.   set numChars = the number of chars in phrase
  53.   return chars(phrase, 1, numChars-1)
  54. end
  55.  
  56. -- --------------------------------------------------------
  57. -- Handler removePunctuationFromBeginning returns the given phrase
  58. -- without the beginning puncutation
  59.  
  60. on removePunctuationFromBeginning phrase
  61.   set numChars = the number of chars in phrase
  62.   return chars(phrase, 2, numChars)
  63. end